/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DO_THUMBNAIL_BG_OPERATION_PROCESSOR_H
#define DO_THUMBNAIL_BG_OPERATION_PROCESSOR_H

#include "medialibrary_base_bg_processor.h"
#include "timer.h"

#include <memory>
#include <mutex>
#include <string>

namespace OHOS {
namespace Media {
#define EXPORT __attribute__ ((visibility ("default")))
class DoThumbnailBgOperationProcessor final : public MediaLibraryBaseBgProcessor {
public:
    DoThumbnailBgOperationProcessor() {}
    ~DoThumbnailBgOperationProcessor() {}

    int32_t Start(const std::string &taskExtra) override;
    int32_t Stop(const std::string &taskExtra) override;

private:
    static void DoThumbnailBgOperation();
    static void StopThumbnailBgOperation();

    static void StartTimer();
    static void StopTimer(bool needReport);

    static void TryStopThumbnailBgOperation();
    static void UpdateCurrentStatusForTask();
    static void UpdateThumbnailBgGenerationStatus(bool isCharging);

    static int32_t QueryThumbAstc(int32_t &thumbAstcCount);
    static int32_t QueryThumbTotal(int32_t &thumbTotalCount);

    static const std::string taskName_;

    static std::recursive_mutex mutex_;
    static Utils::Timer timer_;
    static uint32_t startTimerId_;
    static int32_t countTimer_;
    static bool thumbnailBgGenerationStatus_;
    static int32_t pollingInterval_;
};
} // namespace Media
} // namespace OHOS
#endif  // DO_THUMBNAIL_BG_OPERATION_PROCESSOR_H
